home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / rsxwdk2s.zip / RSXWDK / LIBSRC / WIN / INT86.S < prev    next >
Text File  |  1994-12-16  |  3KB  |  178 lines

  1. /    struct REGPACK {
  2. / 0    unsigned short ax, h_ax;
  3. / 1    unsigned short bx, h_bx;
  4. / 2    unsigned short cx, h_cx;
  5. / 3    unsigned short dx, h_dx;
  6. / 4    unsigned short si, h_si;
  7. / 5    unsigned short di, h_di;
  8. / 6    unsigned short flags, h_flags;
  9. /    }
  10.  
  11.  
  12.     .data
  13. old_esp:
  14.     .long 0
  15. old_ss:
  16.     .long 0
  17. new_ss:
  18.     .long 0
  19.  
  20.     .text
  21.  
  22. / int _intr (int int_num, struct REGPACK *);
  23.  
  24.     .globl __intr
  25.     .align    2, 0x90
  26. __intr:
  27.     pushl    %ebp
  28.     movl    %esp, %ebp
  29.  
  30.     pushl    %ebx
  31.     pushl    %esi
  32.     pushl    %edi
  33.  
  34. /    save selector for new 16bit stack
  35.     pushl    %esp
  36.     call    __rsx_stack16_sel
  37.     popl    %edx
  38.     movl    %eax, new_ss
  39.  
  40.     movl    $0xc3c331cd, %eax
  41.     movb    8(%ebp), %ah
  42.     movl    %eax, __text - 176
  43.  
  44.     movl    12(%ebp), %ebx
  45.     movl    0*4(%ebx), %eax
  46.     movl    2*4(%ebx), %ecx
  47.     movl    3*4(%ebx), %edx
  48.     movl    4*4(%ebx), %esi
  49.     movl    5*4(%ebx), %edi
  50.     movl    1*4(%ebx), %ebx
  51.  
  52.     pushl    %ebp
  53.     pushl    %es
  54.  
  55. /    Save old stack
  56.     movw    %ss, old_ss
  57.     movl    %esp, old_esp
  58.  
  59. /    Build 16bit stack, do not confuse Windows
  60.     movw    new_ss, %ss
  61.     andl    $0xFFFF, %esp
  62.  
  63.     call    __text - 176
  64.  
  65. /    Get old stack
  66.     movw    %cs:old_ss, %ss
  67.     movl    %cs:old_esp, %esp
  68.  
  69.     popl    %es
  70.     popl    %ebp
  71.  
  72.     pushl    %ebx
  73.     movl    12(%ebp), %ebx
  74.     movl    %eax, 0*4(%ebx)
  75.     popl    2*4(%ebx)
  76.     movl    %ecx, 2*4(%ebx)
  77.     movl    %edx, 3*4(%ebx)
  78.     movl    %esi, 4*4(%ebx)
  79.     movl    %edi, 5*4(%ebx)
  80.     pushf
  81.     popl    6*4(%ebx)
  82.     movl    0*4(%ebx), %eax
  83.  
  84.     popl    %edi
  85.     popl    %esi
  86.     popl    %ebx
  87.  
  88.     leave
  89.     ret
  90.  
  91.  
  92. / int _intxr (int int_num, struct REGPACK *, struct SEGPACK *);
  93.  
  94.     .globl __intxr
  95.     .align    2, 0x90
  96. __intxr:
  97.     pushl    %ebp
  98.     movl    %esp, %ebp
  99.  
  100.     pushl    %ebx
  101.     pushl    %esi
  102.     pushl    %edi
  103.  
  104. /    save selector for new 16bit stack
  105.     pushl    %esp
  106.     call    __rsx_stack16_sel
  107.     popl    %edx
  108.     movl    %eax, new_ss
  109.  
  110.     movl    $0xc3c331cd, %eax
  111.     movb    8(%ebp), %ah
  112.     movl    %eax, __text - 176
  113.  
  114.     movl    12(%ebp), %ebx
  115.     movl    0*4(%ebx), %eax
  116.     movl    2*4(%ebx), %ecx
  117.     movl    3*4(%ebx), %edx
  118.     movl    4*4(%ebx), %esi
  119.     movl    5*4(%ebx), %edi
  120.  
  121.     pushl    %ds
  122.     pushl    %es
  123.     pushl    %ebp
  124.  
  125. /    Save old stack
  126.     movw    %ss, old_ss
  127.     movl    %esp, old_esp
  128.  
  129.     pushl    1*4(%ebx)
  130.     movl    16(%ebp), %ebx
  131.     pushw    0*2(%ebx)
  132.     pushw    1*2(%ebx)
  133.     popw    %es
  134.     popw    %ds
  135.     popl    %ebx
  136.  
  137. /    Build 16bit stack, do not confuse Windows
  138.     movw    %cs:new_ss, %ss
  139.     andl    $0xFFFF, %esp
  140.  
  141.     call    __text - 176
  142.  
  143. /    Get old stack
  144.     movw    %cs:old_ss, %ss
  145.     movl    %cs:old_esp, %esp
  146.  
  147.     popl    %ebp
  148.     popl    %es
  149.     popl    %ds
  150.  
  151.     pushl    %ebx
  152.     movl    12(%ebp), %ebx
  153.     movl    %eax, 0*4(%ebx)
  154.     popl    2*4(%ebx)
  155.     movl    %ecx, 2*4(%ebx)
  156.     movl    %edx, 3*4(%ebx)
  157.     movl    %esi, 4*4(%ebx)
  158.     movl    %edi, 5*4(%ebx)
  159.     pushf
  160.     popl    6*4(%ebx)
  161.     movl    0*4(%ebx), %eax
  162.  
  163.     popl    %edi
  164.     popl    %esi
  165.     popl    %ebx
  166.  
  167.     leave
  168.     ret
  169.  
  170.  
  171.     .globl _GetDS
  172.     .align    2, 0x90
  173. _GetDS:
  174.     movw    %ds, %ax
  175.     movzwl    %ax, %eax
  176.     ret
  177.  
  178.